﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using QInfrastructure.Interfaces.SystemManager;
using QInfrastructure.Models;
using QInfrastructure.Models.SystemManager;
using QInfrastructure.WebCore.Filters;

namespace QInfrastructure.WebCore.Areas.SystemManager;

[Authorize]
[Area("SystemManager")]
public class SystemMenuController : QBaseController
{
    public IActionResult Index()
    {
        return View();
    }


    [QPermission(QPermissionKey.Add | QPermissionKey.Update)]
    public IActionResult SystemMenuEdit(int Id)
    {
       var info=GetService<TSystemMenu>().GetSystemMenuById(Id);
        return View(info);
    }
    [QPermission(QPermissionKey.Query)]
    public IActionResult SystemMenuQuery(SystemMenu condition)
    {
        var res = GetService<TSystemMenu>().GetSystemMenuQuery(condition);
        return Json(res);
    }

    [QPermission(QPermissionKey.Delete)]
    public IActionResult SystemMenuDelete(int Id)
    {
        GetService<TSystemMenu>().DeleteSystemMenu(Id);
        return Success();
    }


    [QPermission(QPermissionKey.Add | QPermissionKey.Update)]
    public IActionResult SystemMenuSave(SystemMenu info)
    {
        GetService<TSystemMenu>().AddOrUpdateSystemMenu(info);
        return Success();
    }





    /// <summary>
    /// 导航菜单查询
    /// </summary>
    /// <param name="UserId"></param>
    /// <returns></returns>
    public IActionResult GetSystemMenuTree(Guid UserId)
    {
		var res = GetService<TSystemMenu>().GetSystemMenuTree(UserId);
		return Json(res);
	}







}
